******************************************************************************************************************
*		
*		Tile: Partisan Poll Watchers and Electoral Manipulation
*
*		Authors: Sergio Ascencio and Miguel R. Rueda
* 
*		Description: Gives results from appendix that do not involve strategic model estimation carried out at the polling station level
*
******************************************************************************************************************




cd "C:\Users\mrueda\Documents\Emory\Papers\Party_Delegates\data\Controles\"
use replication_polling_station_level.dta,clear

**Figure 2**
graph bar (mean) RC_PRI_c, over(other_reps_PRI) scheme(s2mono) blabel(bar,format(%9.3f))
graph bar (mean) RC_PAN_c, over(other_reps_PAN) scheme(s2mono) blabel(bar,format(%9.3f))

**Figure 1**
collapse (mean) RC_PRI_c RC_PAN_c RC_others, by(year)
twoway (line RC_PRI_c year, sort) (line RC_PAN_c year, sort)  (line RC_others year, sort)

use replication_polling_station_level.dta

*Keep only precincts that did not change districts in 2005 when clustering standard errors by district  
drop if same_district==0&year<2006 
xtset id_casilla_mesas year2, generic

***Appendix***
**Table 5 (last two columns)*

reg d_irregular c.RC_PAN_c##c.RC_PRI_c RC_others lcasillas school_ic l_margin lpop local gov_PAN gov_PRI c.d_registered_rep_PRI_c c.d_registered_rep_PAN_c d_registered_rep_others c.RC_PAN_c_pr##c.RC_PRI_c_pr RC_others_pr c.d_registered_rep_PAN_c_pr##c.d_registered_rep_PRI_c_pr d_registered_rep_others_pr if year==2009&non_regis==0,  vce(cluster state_district)
areg d_irregular c.RC_PAN_c##c.RC_PRI_c RC_others lcasillas school_ic l_margin lpop local gov_PAN gov_PRI c.d_registered_rep_PRI_c c.d_registered_rep_PAN_c d_registered_rep_others c.RC_PAN_c_pr##c.RC_PRI_c_pr RC_others_pr c.d_registered_rep_PAN_c_pr##c.d_registered_rep_PRI_c_pr d_registered_rep_others_pr if year==2009&non_regis==0, a(state_district) vce(cluster state_district)


**Table 6** 
xtset id_casilla_mesas year2, generic
foreach var in PAN PRI {
	xtreg share_`var'_c  c.RC_PAN_c##c.RC_PRI_c RC_others lcasillas lpop l_margin school_ic  local gov_`var' i.year c.RC_PAN_c_pr##c.RC_PRI_c_pr RC_others_pr c.d_registered_rep_PAN_c##c.d_registered_rep_PRI_c d_registered_rep_others c.d_registered_rep_PAN_c_pr##c.d_registered_rep_PRI_c_pr d_registered_rep_others_pr if non_regis==0,fe vce (cluster state_district)
}
foreach var in turnout share_null {
	xtreg `var'  c.RC_PAN_c##c.RC_PRI_c RC_others lcasillas lpop l_margin school_ic  local gov_PRI gov_PAN i.year c.RC_PAN_c_pr##c.RC_PRI_c_pr RC_others_pr c.d_registered_rep_PAN_c##c.d_registered_rep_PRI_c d_registered_rep_others c.d_registered_rep_PAN_c_pr##c.d_registered_rep_PRI_c_pr d_registered_rep_others_pr if non_regis==0,fe vce (cluster state_district)
}
